package net.oschina.arvin.admin.web.controller;

import net.oschina.arvin.admin.model.vo.ConverterVO;
import net.oschina.arvin.admin.web.converter.DateFormatter;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 测试 Converter
 *
 * @author Arvin
 * @time 2017/11/20 22:10
 */
@RestController
@RequestMapping("/test/converter")
public class TestConverterController {

    @RequestMapping(value = "/date.do", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
    public Date date(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(simpleDateFormat.format(date));
        return date;
    }

    @RequestMapping("/jsonToObject.do")
    public ConverterVO jsonToObject(ConverterVO converterVO) {
        return converterVO;
    }

}
